package com.undsf.utility;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Arathi on 2016/10/13.
 */
public class Node {
    public String key;
    public String parentKey;
    // public List<String> childrenKeys;
    public Object referrer;

    // 等所有node都加载完以后再写入这两个值
    public Node parent;
    public List<Node> children;

    public Node(String key, String parentKey, Object referrer) {
        this.key = key;
        this.parentKey = parentKey;
        this.referrer = referrer;
        // this.childrenKeys = new ArrayList<String>();
        this.children = new ArrayList<Node>();
    }

    public void addChild(Node child) {
        children.add(child);
    }

    @Override
    public String toString() {
        String k = key;
        if (parentKey != null && !parentKey.isEmpty()) {
            k += ":" + parentKey;
        }
        return k + " -> " + referrer.toString();
    }
}
